/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.utn.tpsimulacion02;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author aaltamir
 */

public class LibPoisson {
    
    public static List<Double> generarNumeros(int cantidad, int lambda){
        List listaNumeros = new ArrayList<Double>();
        for(int i =0; i<cantidad;i++){
            listaNumeros.add(callPoisson(lambda));
        }
        return listaNumeros;
    }
    
    
    private static double callPoisson(int lambda){
        double p =1;
        double x = 0;
        int l = lambda;
        double a = Math.pow(Math.E,-l);
        do {
            double u = Math.random();
            p*=u;
            x++;
        } 
        while (p>=a);
        return x;
    }
    
}
